package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.RemoteBrandService;
import com.spzx.product.api.domain.Brand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * ClassName: RemoteBrandFallbackFactory
 * Package: com.spzx.product.api.factory
 * Description:
 *
 * @Author ycy
 * @Create 2024/8/10 14:06
 * @Version 1.0
 */
@Component
public class RemoteBrandFallbackFactory implements FallbackFactory<RemoteBrandService>{
    private static final Logger log = LoggerFactory.getLogger(RemoteBrandFallbackFactory.class);


    @Override
    public RemoteBrandService create(Throwable cause) {
        log.error("商品服务调用失败:{}",cause.getMessage());
        return new RemoteBrandService() {
            @Override
            public R<List<Brand>> getBrandAllList(String source) {
                return R.fail("调用商品服务的商标接口失败:"+ cause.getMessage());
            }
        };
    }
}
